package cn.img;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;

public class Img3 {
    public static void main(String[] args) throws Exception{
        var img = new BufferedImage(300,300,2);
        var g = img.createGraphics();
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);

        g.setColor(Color.ORANGE);
        g.fillRect(0,0,300,300);

        //在正中央画一个圆形
        int x = 260;
        int y = 260;
        g.setColor(new Color(255,0,0));
        g.fillOval(x,y,100,100);
        g.dispose();
        ImageIO.write(img,"png",new File("my.png"));
        Runtime.getRuntime().exec("cmd /k start my.png");
    }
}
